//
//  ImmediatelyRepayController.m
//  51易借
//
//  Created by 张睿 on 2017/8/29.
//  Copyright © 2017年 张睿. All rights reserved.
//

#import "ImmediatelyRepayController.h"
#import "RepayTableViewCell.h"
#import "ServiceCostView.h"
#import "LLPayUtil.h"
#import "LLOrder.h"
#import "BorrowDetailModel.h"
#import "ShenHeProgressView.h"
#import "BorrowRecodeController.h"
#import "ContractWebController.h"
#import "HomeViewController.h"
#import "RepaymentViewController.h"

///*! TODO: 修改两个参数成商户自己的配置 */
//static NSString *kLLOidPartner =
//@"201708010000752179";    //认证支付 或 分期付 测试商户号
////@"201408071000001546";      //快捷支付测试商户号
//static NSString *kLLPartnerKey =
//@"0jaK/7Fx1S6/0gW+0zt1q+fp5tjVTgI2YRCIVyPYbMOG/iHq8xCdSvsGyOafChpbYUwKNi9ZcxAJBGoYyShP3v/bFpal3LUwqXlGNVpFzHZ4bNJvyge2dK7SWN7ZNHYa9TSBmMKnM6I5c169yhdFNhVGFBNUwHJFNLNm3Kf9egQ=";      //认证支付 或 分期付 测试商户号 密钥
////@"201408071000001546_test_20140815";   //快捷支付测试商户号 测试商户号 密钥
//static NSString *signType = @"RSA"; //签名方式RSA||MD5
//
///*! 接入什么支付产品就改成那个支付产品的LLPayType，如快捷支付就是LLPayTypeQuick */
static LLPayType payType = LLPayTypeInstalments;
//
//static NSString *userId = @"13890091003";  //user_id,必传
//
///*！ 若是签约、认证、实名快捷、分期付等请填入以下内容 */
//static NSString *cardNumber = @"6227003571560105249";  //卡号
//static NSString *acctName = @"张睿";    //姓名
//static NSString *idNumber = @"510304199303020512";    //身份证号


@interface ImmediatelyRepayController ()<UITableViewDelegate,UITableViewDataSource,LLPaySdkDelegate>
@property (nonatomic,strong)ShenHeProgressView * progressView;
@property (nonatomic,strong)BorrowDetailModel * detailModel;
@property (nonatomic, weak)UIView * topView;
@property (nonatomic, weak)UIView * backView;
@property (nonatomic, strong)ServiceCostView * serviceCostView;
@property (nonatomic, weak)UIView * inputTopView;
@property (nonatomic, weak)UIImageView * showImageView;
@property (nonatomic, weak)UILabel * showLabel;
@property (nonatomic, weak)UIImageView * rightImageView;
@property (nonatomic, weak)UIImageView * moneySymbol;


@property (nonatomic, weak)UIView * inputBottomView;
@property (nonatomic,strong)UIView * inputDetailView;
@property (nonatomic,strong)UIView * moneyView;
@property (nonatomic,strong)NSMutableArray * numbersViews;



@property (nonatomic, strong)UIButton * infoButton;
@property (nonatomic, weak)UIButton * infoButton1;

@property (nonatomic, strong)UITableView * tableView;
@property (nonatomic,strong)UITableView * tableView1;
@property (nonatomic, weak)UIButton * repayButton;
@property (nonatomic, strong)NSArray * titleArray;
@property (nonatomic, strong)NSArray * detailArray;

@property (nonatomic, strong) LLOrder *order;
@property (nonatomic, strong) NSMutableDictionary *orderDic;
@property (nonatomic, assign)BOOL isHave;
@property (nonatomic, copy)NSString * url;

//@property (nonatomic, weak)UIButton * repaymentInfoImageView;
@property (nonatomic, weak)UILabel * readyMoneyLabel;
@property (nonatomic, weak)UILabel * readyMoneyValueLabel;
@property (nonatomic, weak)UILabel * overdueMoneyLabel;
@property (nonatomic, weak)UILabel * overdueMoneyValueLabel;
@property (nonatomic, weak)UILabel * autoRepayMoneyLabel;
@property (nonatomic, weak)UILabel * autoRepayMoneyValueLabel;

//平台服务费
@property (nonatomic,copy)NSString * platformServiceFee;
//信息认证费用
@property (nonatomic,copy)NSString * infoAuthFee;
//风控服务费
@property (nonatomic,copy)NSString * riskServiceFee;
//风控准备金
@property (nonatomic,copy)NSString * riskPrepareFee;

@property (nonatomic,copy)NSString * explationString;

@end

@implementation ImmediatelyRepayController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = BACK_COLOR;
    [self getLoanDetail];
    [self setupNavBar];
    [self setupNSNoti];
    [self setupUI];
    
}


- (void)setupNavBar{
    
    self.title = @"还款";
    
    UIButton * backButton = [[UIButton alloc] init];
    
    backButton.frame = CGRectMake(15 * SCREENH6, 5 * SCREENH6, 12 * SCREENH6, 20 * SCREENH6);
    [backButton setImage:[UIImage imageNamed:@"箭头"] forState:UIControlStateNormal];
    [backButton addTarget:self action:@selector(backToLastView) forControlEvents:UIControlEventTouchUpInside];
    
    UIBarButtonItem * leftButton = [[UIBarButtonItem alloc] initWithCustomView:backButton];
    
    self.navigationItem.leftBarButtonItem = leftButton;
}

-(void)setUpMoneyView:(NSInteger)money
{
    [self.moneyView.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        [obj removeFromSuperview];
    }];
    [self.numbersViews removeAllObjects];
    
    NSArray * numbers = [self nsinterLength:money];
    
    UIImageView * moneySymbol = [UIImageView new];
    
    moneySymbol.image = [UIImage imageNamed:@"¥"];
    
    [self.numbersViews addObject:moneySymbol];
    [self.moneyView addSubview:moneySymbol];
    for(NSString * number in numbers)
    {
        UIButton * button = [self setupButton:number];
        [self.moneyView addSubview:button];
        [self.numbersViews insertObject:button atIndex:1];
    }
    
}


- (NSArray*)nsinterLength:(NSInteger)x{
    if(x<=0)
        return @[@"0"];
    NSMutableArray * numbers = [NSMutableArray array];
    NSInteger sum=0,j=1;
    while( x >= 1 ) {
//        NSLog(@"%zd位数是 : %zd\n",j,x%10);
        [numbers insertObject:[NSString stringWithFormat:@"%zd",x%10] atIndex:0];
        x=x/10;
        sum++;
        j=j*10;
    }
    
    return numbers;
}


- (void)setupNSNoti{
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showServiceView) name:@"showServiceView" object:nil];

    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(watchContract) name:@"watchContract" object:nil];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(hiddenServiceView) name:@"hiddenView" object:nil];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pushWebView) name:@"pushWebView" object:nil];
}


- (void)setupUI{
    
    self.titleArray = @[@"借款编号",@"借款金额",@"借款利息",@"借款费用",@"借款时间",@"还款日期",@"借款合同"];
    
    UIView * topView = [UIView new];
    
    topView.backgroundColor = TOTAL_COLOR;
    
    self.topView = topView;
    
    [self.view addSubview:self.topView];
    
    
    UIView * inputTopView = [UIView new];
    
    inputTopView.backgroundColor = [UIColor whiteColor];
    inputTopView.layer.borderColor = [ColorWithRGB(0xe6e6e6) CGColor];
    inputTopView.layer.borderWidth = 0.5 * SCREENH6;
    
    self.inputTopView = inputTopView;
    
    [self.view addSubview:self.inputTopView];
    
    
    UIImageView * showImageView = [UIImageView new];
    
    showImageView.image = [UIImage imageNamed:@"标题"];
    
    self.showImageView = showImageView;
    
    [self.inputTopView addSubview:self.showImageView];
    
    //Arial-BoldItalicMT
    UILabel * showLabel = [UILabel new];
    
    showLabel.text = @"需还款金额(元)";
    showLabel.textAlignment = NSTextAlignmentCenter;
    showLabel.textColor = ColorWithRGB(0xfff7b0);
    showLabel.font = [UIFont boldSystemFontOfSize:15 * SCREENH6];
    CGAffineTransform matrix = CGAffineTransformMake(1, 0, tanf(-15 * (CGFloat)M_PI / 180), 1, 0, 0);
    showLabel.transform = matrix;
    
    self.showLabel = showLabel;
    
    [self.showImageView addSubview:self.showLabel];
    
    UIImageView * rightImageView = [UIImageView new];
    
    rightImageView.image = [UIImage imageNamed:@"待还款图标"];
    
    self.rightImageView = rightImageView;
    
    [self.inputTopView addSubview:self.rightImageView];
    
    
    self.moneyView = [UIView new];
    [self.inputTopView addSubview:self.moneyView];
    
    
    [self setUpMoneyView:0];
    
    UIView * inputBottomView = [UIView new];
    
    inputBottomView.backgroundColor = [UIColor whiteColor];
    inputBottomView.layer.borderColor = [ColorWithRGB(0xe6e6e6) CGColor];
    inputBottomView.layer.borderWidth = 0.5 * SCREENH6;
    //处理圆角
    inputBottomView.layer.cornerRadius = 5.0f * SCREENH6;
//    inputBottomView.backgroundColor = [UIColor redColor];
    
    self.inputBottomView = inputBottomView;
    
    [self.view addSubview:self.inputBottomView];
    
    
    UIButton * infoButton = [[UIButton alloc] init];//WithFrame:CGRectMake(0, 0, 60 * SCREENH6, 19 * SCREENH6)];
    
    infoButton.titleLabel.font = [UIFont systemFontOfSize:12 * SCREENH6];
    [infoButton setBackgroundImage:[UIImage imageNamed:@"借款明细"] forState:UIControlStateNormal];
    [infoButton setTitle:@"借款明细" forState:UIControlStateNormal];
    infoButton.userInteractionEnabled = NO;
//    [self.infoButton setBackgroundColor:[UIColor blueColor]];
    
    self.infoButton = infoButton;
    
    [self.inputBottomView addSubview:self.infoButton];
//    [self.view bringSubviewToFront:self.infoButton];
    
    
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 25 * SCREENH6, SCREEN_WIDTH, 220 * SCREENH6)];
    
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.backgroundColor = [UIColor clearColor];
    
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.tableView.bounces = NO;
    
    [self.tableView registerClass:[RepayTableViewCell class] forCellReuseIdentifier:@"RepatCell"];
    
    [self.inputBottomView addSubview:self.tableView];
    
    
    
    
    self.tableView1 = [[UITableView alloc] initWithFrame:CGRectMake(0, 25 * SCREENH6, SCREEN_WIDTH, 95 * SCREENH6)];
    
    self.tableView1.delegate = self;
    self.tableView1.dataSource = self;
    self.tableView1.backgroundColor = [UIColor clearColor];

    
    self.tableView1.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.tableView1.bounces = NO;
    
    [self.tableView1 registerClass:[RepayTableViewCell class] forCellReuseIdentifier:@"RepatCell1"];

    
    
    
    
    UIView *  inputContentView= [UIView new];
    
    inputContentView.backgroundColor = [UIColor whiteColor];
    inputContentView.layer.borderColor = [ColorWithRGB(0xe6e6e6) CGColor];
    inputContentView.layer.borderWidth = 0.5 * SCREENH6;
    //处理圆角
    inputContentView.layer.cornerRadius = 5.0f * SCREENH6;
    
    self.inputDetailView = inputContentView;
    self.inputDetailView.clipsToBounds = YES;
    [self.view addSubview:self.inputDetailView];
    
    
//    UIButton * repaymentInfoImageView = [UIButton new];
//    
//    [repaymentInfoImageView setBackgroundImage:[UIImage imageNamed:@"还款详情"] forState:UIControlStateNormal];
//    [repaymentInfoImageView setTitle:@"还款明细" forState:UIControlStateNormal];
//    repaymentInfoImageView.titleLabel.font = [UIFont systemFontOfSize:10 * SCREENH6];
//    [repaymentInfoImageView setTintColor:[UIColor whiteColor]];
//    [repaymentInfoImageView setEnabled:NO];
//    
//    self.repaymentInfoImageView = repaymentInfoImageView;
//    
//    [self.inputDetailView addSubview:self.repaymentInfoImageView];
    
    UIButton * infoButton1 = [UIButton new];
    
    infoButton1.titleLabel.font = [UIFont systemFontOfSize:12 * SCREENH6];
    [infoButton1 setBackgroundImage:[UIImage imageNamed:@"还款明细"] forState:UIControlStateNormal];
    [infoButton1 setTitle:@"还款明细" forState:UIControlStateNormal];
    infoButton1.userInteractionEnabled = NO;
    
    self.infoButton1 = infoButton1;
    
    [self.inputDetailView addSubview:self.infoButton1];
    
    UILabel * readyMoneyLabel = [UILabel new];
    
    readyMoneyLabel.textColor = ColorWithRGB(0x303c41);
    readyMoneyLabel.font = [UIFont systemFontOfSize:13 * SCREENH6];
    readyMoneyLabel.textAlignment = NSTextAlignmentLeft;
    readyMoneyLabel.text = @"已还金额";
    
    self.readyMoneyLabel = readyMoneyLabel;
    
    [self.inputDetailView addSubview:self.readyMoneyLabel];
    
    
    UILabel * readyMoneyValueLabel = [UILabel new];
    
    readyMoneyValueLabel.textColor = ColorWithRGB(0x7f7f7f);
    readyMoneyValueLabel.font = [UIFont systemFontOfSize:13 * SCREENH6];
    readyMoneyValueLabel.textAlignment = NSTextAlignmentRight;
    readyMoneyValueLabel.text = @"1000.00元";
    
    self.readyMoneyValueLabel = readyMoneyValueLabel;
    
    [self.inputDetailView addSubview:self.readyMoneyValueLabel];
    
    
    UILabel * overdueMoneyLabel = [UILabel new];
    
    overdueMoneyLabel.textColor = ColorWithRGB(0x303c41);
    overdueMoneyLabel.font = [UIFont systemFontOfSize:13 * SCREENH6];
    overdueMoneyLabel.textAlignment = NSTextAlignmentLeft;
    overdueMoneyLabel.text = @"逾期滞纳金";
    
    self.overdueMoneyLabel = overdueMoneyLabel;
    
    [self.inputDetailView addSubview:self.overdueMoneyLabel];
    
    
    UILabel * overdueMoneyValueLabel = [UILabel new];
    
    overdueMoneyValueLabel.textColor = ColorWithRGB(0x7f7f7f);
    overdueMoneyValueLabel.font = [UIFont systemFontOfSize:13 * SCREENH6];
    overdueMoneyValueLabel.textAlignment = NSTextAlignmentRight;
    overdueMoneyValueLabel.text = @"25.00元";
    
    self.overdueMoneyValueLabel = overdueMoneyValueLabel;
    
    [self.inputDetailView addSubview:self.overdueMoneyValueLabel];
    
    UILabel * autoRepayMoneyLabel = [UILabel new];
    
    autoRepayMoneyLabel.textColor = ColorWithRGB(0x303c41);
    autoRepayMoneyLabel.font = [UIFont systemFontOfSize:13 * SCREENH6];
    autoRepayMoneyLabel.textAlignment = NSTextAlignmentLeft;
    autoRepayMoneyLabel.text = @"自动扣款";
    
    self.autoRepayMoneyLabel = autoRepayMoneyLabel;
    
    [self.inputDetailView addSubview:self.autoRepayMoneyLabel];
    
    UILabel * autoRepayMoneyValueLabel = [UILabel new];
    
    autoRepayMoneyValueLabel.textColor = ColorWithRGB(0x7f7f7f);
    autoRepayMoneyValueLabel.font = [UIFont systemFontOfSize:13 * SCREENH6];
    autoRepayMoneyValueLabel.textAlignment = NSTextAlignmentRight;
    autoRepayMoneyValueLabel.text = @"2017-06-21";
    
    self.autoRepayMoneyValueLabel = autoRepayMoneyValueLabel;
    
    [self.inputDetailView addSubview:self.autoRepayMoneyValueLabel];
    
    
    self.progressView = [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([ShenHeProgressView class]) owner:nil options:nil] lastObject];
    
    
    [self.view addSubview:self.progressView];
    
    
    
    
    
    UIButton * repayButton = [UIButton new];
    //300 * 42
    [repayButton setTitle:@"立即还款" forState:UIControlStateNormal];
    [repayButton setBackgroundImage:[UIImage imageNamed:@"登录"] forState:UIControlStateNormal];
    [repayButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [repayButton addTarget:self action:@selector(didRepayButton) forControlEvents:UIControlEventTouchUpInside];
    repayButton.titleLabel.font = [UIFont systemFontOfSize:14 * SCREENH6];
    
    self.repayButton = repayButton;
    
    [self.view addSubview:self.repayButton];
    self.inputBottomView.hidden = YES;
    self.inputDetailView.hidden = YES;
    self.progressView.hidden = YES;
    self.repayButton.hidden = YES;
}


- (void)viewDidLayoutSubviews{
    
    [self.topView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.leading.trailing.mas_equalTo(self.view);
        make.height.mas_equalTo(64);
    }];
    
    [self.inputTopView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.view).offset(6 * SCREENH6);
        make.top.mas_equalTo(self.topView.mas_bottom).offset(10 * SCREENH6);
        make.trailing.mas_equalTo(self.view).offset(-6 * SCREENH6);
        make.height.mas_equalTo(155 * SCREENH6);
    }];
    
    [self.showImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.view);
        make.top.mas_equalTo(self.inputTopView);
        make.height.mas_equalTo(48 * SCREENH6);
        make.width.mas_equalTo(193 * SCREENH6);
    }];
    
    [self.showLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.showImageView).offset(7 * SCREENH6);
        make.centerY.mas_equalTo(self.showImageView).offset(5 * SCREENH6);
    }];
    
    [self.rightImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(59 * SCREENH6);
        make.height.mas_equalTo(46 * SCREENH6);
        make.top.mas_equalTo(self.inputTopView).offset(5 * SCREENH6);
        make.trailing.mas_equalTo(self.inputTopView).offset(-5 * SCREENH6);
    }];
    
    
    [self.moneyView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.inputTopView).offset(65);
        make.leading.mas_equalTo(self.inputTopView).offset(0);
        make.trailing.mas_equalTo(self.inputTopView).offset(0);;
        make.height.mas_equalTo(50 * SCREENH6);
    }];
    
    [self updateMoneyLayout];
    
    [self.inputBottomView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.trailing.mas_equalTo(self.inputTopView);
        make.height.mas_equalTo(252.5 * SCREENH6);
        make.top.mas_equalTo(self.inputTopView.mas_bottom).offset(5 * SCREENH6);
    }];
    
    [self.infoButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.leading.mas_equalTo(self.inputBottomView);
        make.width.mas_equalTo(60 * SCREENH6);
        make.height.mas_equalTo(19 * SCREENH6);
    }];
    
    
    
    [self.inputDetailView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.trailing.mas_equalTo(self.inputTopView);
        make.height.mas_equalTo(96.5 * SCREENH6);
        make.top.mas_equalTo(self.inputBottomView.mas_bottom).offset(5 * SCREENH6);
    }];
    
    [self.infoButton1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.leading.mas_equalTo(self.inputDetailView);
        make.width.mas_equalTo(59 * SCREENH6);
        make.height.mas_equalTo(19 * SCREENH6);
    }];
    [self.progressView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.trailing.mas_equalTo(self.view);
        make.height.mas_equalTo(SCREENH_HEIGHT-(252+155+25+64)*SCREENH6);
        make.top.mas_equalTo(self.inputBottomView.mas_bottom).offset(5 * SCREENH6);
    }];
    
    [self.repayButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.view);
        make.top.mas_equalTo(self.inputBottomView.mas_bottom).offset(48 * SCREENH6);
        make.width.mas_equalTo(300 * SCREENH6);
        make.height.mas_equalTo(42 * SCREENH6);
    }];
//    @property (nonatomic, weak)UILabel * readyMoneyLabel;
//    @property (nonatomic, weak)UILabel * readyMoneyValueLabel;
//    @property (nonatomic, weak)UILabel * overdueMoneyLabel;
//    @property (nonatomic, weak)UILabel * overdueMoneyValueLabel;
//    @property (nonatomic, weak)UILabel * autoRepayMoneyLabel;
//    @property (nonatomic, weak)UILabel * autoRepayMoneyValueLabel;
    [self.readyMoneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.infoButton1.mas_bottom).offset(10 * SCREENH6);
        make.leading.mas_equalTo(self.inputDetailView).offset(15 * SCREENH6);
    }];
    
    [self.readyMoneyValueLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.readyMoneyLabel);
        make.trailing.mas_equalTo(self.inputDetailView).offset(-40 * SCREENH6);
    }];
    
    [self.overdueMoneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.readyMoneyLabel);
        make.top.mas_equalTo(self.readyMoneyLabel.mas_bottom).offset(5 * SCREENH6);
    }];
    
    [self.overdueMoneyValueLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.overdueMoneyLabel);
        make.trailing.mas_equalTo(self.readyMoneyValueLabel);
    }];
    
    [self.autoRepayMoneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.overdueMoneyLabel);
        make.top.mas_equalTo(self.overdueMoneyLabel.mas_bottom).offset(5 * SCREENH6);
    }];
    
    [self.autoRepayMoneyValueLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.autoRepayMoneyLabel);
        make.trailing.mas_equalTo(self.overdueMoneyValueLabel);
    }];
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if(tableView == self.tableView){
        
        if (self.isHave) {
            
            return self.titleArray.count;
        }else{
            
            return self.titleArray.count - 1;
        }
    
    }else
    {
        return self.detailArray.count;
    }
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if(tableView == self.tableView){
        RepayTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"RepatCell" forIndexPath:indexPath];
        
        cell.titleLabel.text = self.titleArray[indexPath.row];
        
        if (indexPath.row == 3) {
            
            cell.troubleButton.hidden = NO;
        }else{
            
            cell.troubleButton.hidden = YES;
        }
        
        
        if (indexPath.row == 6) {
            
            cell.valueLabel.hidden = YES;
            cell.watchButton.hidden = NO;
        }else{
            
            cell.valueLabel.hidden = NO;
            cell.watchButton.hidden = YES;
        }
        switch (indexPath.row) {
            case 0:
            {
                cell.valueLabel.text = self.detailModel.applyNo;
            }
                break;
            case 1:
            {
               
                cell.valueLabel.text = [NSString stringWithFormat:@"%.2f元", [self.detailModel.borrowAmount floatValue]];

            }
                break;
            case 2:
            {
                cell.valueLabel.text = [NSString stringWithFormat:@"%.2f元", [self.detailModel.basicInterest floatValue]];

            }
                break;
            case 3:
            {
                cell.valueLabel.text = [NSString stringWithFormat:@"%.2f元", [self.detailModel.totalServiceFee floatValue]];

            }
                break;
            case 4:
            {
                
//                cell.valueLabel.text = [Lahelper formattedTimeFromTimeInterval:[self.detailModel.applyTime longLongValue]];

                cell.valueLabel.text = [self timeWithTimeIntervalString:[NSString stringWithFormat:@"%@",self.detailModel.applyTime]];
            }
                break;
            case 5:
            {
                cell.valueLabel.text = [Lahelper formattedTimeFromTimeInterval:[self.detailModel.overdueTime longLongValue]];

            }
                break;
            case 6:
            {
//                cell.valueLabel.text = [Lahelper formattedTimeFromTimeInterval:[self.detailModel.overdueTime longLongValue]];

            }
                break;
            default:
                break;
        }
        return cell;
    }else
    {
         RepayTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"RepatCell1" forIndexPath:indexPath];
        cell.titleLabel.text = self.detailArray[indexPath.row];
        cell.troubleButton.hidden = YES;
        cell.valueLabel.hidden = NO;
        cell.watchButton.hidden = YES;
        switch (indexPath.row) {
            case 0:
            {
                cell.valueLabel.text = [NSString stringWithFormat:@"%.2f元", [self.detailModel.repayTotalAmount floatValue]];

            }
                break;
            case 1:
            {
                if([self.detailModel.unionStatus integerValue]==7)
                {
                    cell.valueLabel.text = [NSString stringWithFormat:@"%.2f元", [self.detailModel.overdueAmount floatValue]];

                }else
                {
                    cell.valueLabel.text = [Lahelper formattedTimeFromTimeInterval:[self.detailModel.paybackTime longLongValue]];

                }
            }
                break;
            case 2:
            {
                cell.valueLabel.text = [Lahelper formattedTimeFromTimeInterval:[self.detailModel.overdueTime longLongValue]];

            }
                break;
            default:
                break;
        }
        return cell;

    }
    
}


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return 31 * SCREENH6;
}


- (UIButton *)setupButton:(NSString *)title{
    
    UIButton * button = [UIButton new];
    
    [button setBackgroundImage:[UIImage imageNamed:@"钱框"] forState:UIControlStateNormal];
    [button setTitle:title forState:UIControlStateNormal];
    button.titleLabel.font = [UIFont fontWithName:@"Arial-BoldMT" size:37 * SCREENH6];
    [button setTitleColor:ColorWithRGB(0xff6600) forState:UIControlStateNormal];
    button.adjustsImageWhenHighlighted = NO;
    
    return button;
}



- (void)showServiceView{
    
    UIView * backView = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    
    backView.backgroundColor = [UIColor blackColor];
    backView.alpha = 0.55;
    self.backView = backView;
    
    [self.navigationController.view addSubview:self.backView];
    
    self.serviceCostView = [[ServiceCostView alloc] initWithFrame:CGRectMake(40 * SCREENH6, 205 * SCREENH6, 302 * SCREENH6, 275 * SCREENH6)];
    
    self.serviceCostView.platformServiceFee = self.platformServiceFee;
    self.serviceCostView.infoAuthFee = self.infoAuthFee;
    self.serviceCostView.riskServiceFee = self.riskServiceFee;
    self.serviceCostView.riskPrepareFee = self.riskPrepareFee;
    self.serviceCostView.explationString = self.explationString;
    
    [self.navigationController.view addSubview:self.serviceCostView];
    
    //下面这段代码是 将bottomView调整到父视图的最上面
    [self.view bringSubviewToFront:self.serviceCostView];
}


- (void)pushWebView{
    
    HIDDEN_TAB;
    
    ContractWebController * contractVC = [ContractWebController new];
    
    contractVC.url = self.url;
    
    [self.navigationController pushViewController:contractVC animated:YES];
}


- (void)hiddenServiceView{
    
    [self.backView removeFromSuperview];
    [self.serviceCostView removeFromSuperview];
}


- (void)watchContract{
    
    
    
}

- (void)didRepayButton{
    
    [self getorderInfoComplete:^(NSDictionary*dic){
        if(self.order){

//            LLPayUtil *payUtil = [[LLPayUtil alloc] init];
            // 进行签名
            [LLPaySdk sharedSdk].sdkDelegate = self;
            [[UINavigationBar appearance] setBarStyle:UIBarStyleBlack];
            //接入什么产品就传什么LLPayType
            [[LLPaySdk sharedSdk] presentLLPaySDKInViewController:self
                                                      withPayType:payType
                                                    andTraderInfo:dic];
            
        }else
        {
            [self showHint:@"未获取到订单信息"];
        }
    }];
    
    
    
}

- (void)backToLastView{
    
    if ([self.borrow isEqualToString:@"0"]) {
        
        BorrowRecodeController * vc = [BorrowRecodeController new];
        vc.frome = @"1";
        
        [self.navigationController pushViewController:vc animated:YES];
    }else if([self.borrow isEqualToString:@"3"] ){
        for (UIViewController *controller in self.navigationController.viewControllers) {
            if ([controller isKindOfClass:[HomeViewController class]]) {
                HomeViewController *revise =(HomeViewController *)controller;
                [self.navigationController popToViewController:revise animated:YES];
            }
        }
        
    }else if ([self.borrow isEqualToString:@"4"]){
        for (UIViewController *controller in self.navigationController.viewControllers) {
            if ([controller isKindOfClass:[RepaymentViewController class]]) {
                RepaymentViewController *revise =(RepaymentViewController *)controller;
                [self.navigationController popToViewController:revise animated:YES];
            }
        }
        
        
    }else{
        
        [self.navigationController popViewControllerAnimated:YES];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/
//- (void)llorder {
//    
//    _order = [[LLOrder alloc] initWithLLPayType:payType];
//    NSString *timeStamp = [LLOrder timeStamp];
//    _order.no_order = [NSString stringWithFormat:@"LL%@",timeStamp];
//    _order.dt_order = timeStamp;
//    _order.card_no = cardNumber;
//    _order.name_goods = @"咖啡";
//    
//}



#pragma - mark 支付结果 LLPaySdkDelegate
// 订单支付结果返回，主要是异常和成功的不同状态
// TODO: 开发人员需要根据实际业务调整逻辑
- (void)paymentEnd:(LLPayResult)resultCode withResultDic:(NSDictionary *)dic {
    [self backInfoComplete:^{
        NSString *msg = @"异常";
        switch (resultCode) {
            case kLLPayResultSuccess: {
                
                [self pushBind:dic complete:^{
                    //                    [self.navigationController popViewControllerAnimated:YES];
                    UIAlertController* alert = [UIAlertController alertControllerWithTitle:@""
                                                                                   message:@"支付成功"
                                                                            preferredStyle:UIAlertControllerStyleAlert];
                    
                    UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleCancel
                                                                          handler:^(UIAlertAction * action) {
                                                                              
                                                                              
                                                                              //响应事件
//                                                                              [self.navigationController popViewControllerAnimated:YES];
                                                                              [self getLoanDetail];
                                                                          }];
                    
                    [alert addAction:defaultAction];
                    [self presentViewController:alert animated:YES completion:nil];
                    
                }];
                
               
                
                
                
            } break;
            case kLLPayResultFail: {
                msg = @"失败";
                UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"支付结果"
                                                                               message:@""
                                                                        preferredStyle:UIAlertControllerStyleAlert];
                [alert addAction:[UIAlertAction actionWithTitle:@"确认"
                                                          style:UIAlertActionStyleDefault
                                                        handler:nil]];
                [self presentViewController:alert animated:YES completion:nil];
            } break;
            case kLLPayResultCancel: {
                msg = @"取消";
                UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"支付结果"
                                                                               message:@""
                                                                        preferredStyle:UIAlertControllerStyleAlert];
                [alert addAction:[UIAlertAction actionWithTitle:@"确认"
                                                          style:UIAlertActionStyleDefault
                                                        handler:nil]];
                [self presentViewController:alert animated:YES completion:nil];
            } break;
            case kLLPayResultInitError: {
                msg = @"sdk初始化异常";
                UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"支付结果"
                                                                               message:@""
                                                                        preferredStyle:UIAlertControllerStyleAlert];
                [alert addAction:[UIAlertAction actionWithTitle:@"确认"
                                                          style:UIAlertActionStyleDefault
                                                        handler:nil]];
                [self presentViewController:alert animated:YES completion:nil];
            } break;
            case kLLPayResultInitParamError: {
                msg = dic[@"ret_msg"];
                UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"支付结果"
                                                                               message:@""
                                                                        preferredStyle:UIAlertControllerStyleAlert];
                [alert addAction:[UIAlertAction actionWithTitle:@"确认"
                                                          style:UIAlertActionStyleDefault
                                                        handler:nil]];
                [self presentViewController:alert animated:YES completion:nil];
            } break;
            default:
                break;
        }
//        NSString *showMsg = [msg stringByAppendingString:[LLPayUtil jsonStringOfObj:dic]];
       
    }];
   
}



-(void)getLoanDetail
{
    ParaModel*para = [ParaModel new];
    para.applyNo = self.loanID;
    
    [[NetworkTool shareManager] POST:[Interfacefile getLoanApplyDetail] Param:[para toDictionary] andWaitStr:@"" waitView:self.view success:^(id  _Nullable responseObject) {
        
//        NSLog(@"Loan==%@",responseObject);
        
        if([[responseObject objectForKey:@"code"]intValue]==0)
        {
            NSDictionary * data = responseObject[@"data"];
            self.isHave = [[data allKeys] containsObject:@"loanContract"];
            
            if (self.isHave) {
                
                self.url = [NSString stringWithFormat:@"%@",data[@"loanContract"]];
            }
            
            self.detailModel = [[BorrowDetailModel alloc] initWithDictionary:[responseObject objectForKey:@"data"] error:nil];
            
//            NSDictionary * data = responseObject[@"data"];
            
            self.platformServiceFee = [NSString stringWithFormat:@"%@",data[@"platformServiceFee"]];
            self.infoAuthFee = [NSString stringWithFormat:@"%@",data[@"infoAuthFee"]];
            self.riskServiceFee = [NSString stringWithFormat:@"%@",data[@"riskServiceFee"]];
            self.riskPrepareFee = [NSString stringWithFormat:@"%@",data[@"riskPrepareFee"]];
            
            float borrowAmount = [data[@"borrowAmount"] floatValue];
            float overdueRate = [data[@"overdueRate"] floatValue];
            float explation = borrowAmount * overdueRate;
            
            self.explationString = [NSString stringWithFormat:@"%.2f",explation];
        }else{
            
            [self showHint:[responseObject objectForKey:@"message"]];
            
            
        }
        [self updateDatas];
    } andFailure:^(NSError * _Nonnull error) {
        [self showHint:@"网络错误"];
    }];
    
}


-(void)updateDatas
{
    self.inputBottomView.hidden = self.detailModel==nil;
    switch ([self.detailModel.unionStatus intValue]) {
           // 记录状态（1.审核中 2.审核未通过 3.审核打款中 4.待还款 5.已逾期 6.还款处理中 7.已还款 8.已逾期还款）
        case 1:
        {
            self.inputDetailView.hidden = YES;
            self.repayButton.hidden = YES;
            self.progressView.hidden = NO;
            self.showLabel.text = @"申请借款(元)";
            self.rightImageView.image = [UIImage imageNamed:@"审核中"];
            
            self.title = @"借款详情";
        }
            break;
        case 2:
        {
            self.inputDetailView.hidden = YES;
            self.repayButton.hidden = YES;
            self.progressView.hidden = NO;
            self.showLabel.text = @"申请借款(元)";
            self.rightImageView.image = [UIImage imageNamed:@"未通过"];

            self.title = @"借款详情";
        }
            break;
        case 3:
        {
            self.inputDetailView.hidden = YES;
            self.repayButton.hidden = YES;
            self.progressView.hidden = NO;
            self.showLabel.text = @"申请借款(元)";
            self.rightImageView.image = [UIImage imageNamed:@"打款中"];
            
            self.title = @"借款详情";
        }
            break;
        case 4:
        {
            self.inputDetailView.hidden = YES;
            self.repayButton.hidden = NO;
            self.progressView.hidden = YES;
            self.showLabel.text = @"需还款金额(元)";
            self.rightImageView.image = [UIImage imageNamed:@"还款中"];

        }
            break;
        case 5:
        {
            self.inputDetailView.hidden = YES;
            self.repayButton.hidden = NO;
            self.progressView.hidden = YES;
            self.showLabel.text = @"需还款金额(元)";
            self.rightImageView.image = [UIImage imageNamed:@"逾期中"];

        }
            break;
        case 6:
        {
            self.inputDetailView.hidden = YES;
            self.repayButton.hidden = NO;
            self.progressView.hidden = NO;
            self.showLabel.text = @"需还款金额(元)";
            self.rightImageView.image = [UIImage imageNamed:@"处理中"];

        }
            break;
        case 7:
        {
            self.inputDetailView.hidden = NO;
            self.repayButton.hidden = YES;
            self.progressView.hidden = YES;
            self.overdueMoneyLabel.hidden = YES;
            self.overdueMoneyValueLabel.hidden = YES;
            
            [self.inputDetailView mas_makeConstraints:^(MASConstraintMaker *make) {
                make.leading.trailing.mas_equalTo(self.inputTopView);
                make.height.mas_equalTo(92.5 * SCREENH6);
                make.top.mas_equalTo(self.inputBottomView.mas_bottom).offset(5 * SCREENH6);
            }];
            
            
            [self.autoRepayMoneyLabel mas_updateConstraints:^(MASConstraintMaker *make) {
                make.top.mas_equalTo(self.readyMoneyLabel.mas_bottom).offset(10 * SCREENH6);
                make.leading.mas_equalTo(self.readyMoneyLabel);
            }];
            
            [self.autoRepayMoneyValueLabel mas_updateConstraints:^(MASConstraintMaker *make) {
                make.centerY.mas_equalTo(self.autoRepayMoneyLabel);
                make.trailing.mas_equalTo(self.readyMoneyValueLabel);
            }];
            
            self.readyMoneyValueLabel.text = [NSString stringWithFormat:@"%.2f元",[self.detailModel.repayTotalAmount floatValue]];
//            self.autoRepayMoneyValueLabel.text = [Lahelper formattedTimeFromTimeInterval:[self.detailModel.paybackTime longLongValue]];
            self.autoRepayMoneyValueLabel.text = [self timeWithTimeIntervalString:[NSString stringWithFormat:@"%@",self.detailModel.paybackTime]];
            
            self.showLabel.text = @"已结清(元)";
            if ([self.detailModel.paybackType intValue] == 1) {
                
                self.autoRepayMoneyLabel.text = @"主动还款";
            }else{
                
                self.autoRepayMoneyLabel.text = @"自动扣款";
            }
          
            self.detailArray = @[@"已还金额",@"自动扣款/主动扣款"];
            self.rightImageView.image = [UIImage imageNamed:@"已还款"];
            self.title = @"借款详情";
        }
            break;
        case 8:
        {
            self.inputDetailView.hidden = NO;
            self.repayButton.hidden = YES;
            self.progressView.hidden = YES;
            self.overdueMoneyLabel.hidden = NO;
            self.overdueMoneyValueLabel.hidden = NO;
            
            [self.inputDetailView mas_makeConstraints:^(MASConstraintMaker *make) {
                make.leading.trailing.mas_equalTo(self.inputTopView);
                make.height.mas_equalTo(120 * SCREENH6);
                make.top.mas_equalTo(self.inputBottomView.mas_bottom).offset(5 * SCREENH6);
            }];
            
            [self.overdueMoneyLabel mas_updateConstraints:^(MASConstraintMaker *make) {
                make.top.mas_equalTo(self.readyMoneyLabel.mas_bottom).offset(10 * SCREENH6);
                make.leading.mas_equalTo(self.readyMoneyLabel);
            }];
            
            [self.overdueMoneyValueLabel mas_updateConstraints:^(MASConstraintMaker *make) {
                make.centerY.mas_equalTo(self.autoRepayMoneyLabel);
                make.trailing.mas_equalTo(self.readyMoneyValueLabel);
            }];
            
            
            [self.autoRepayMoneyLabel mas_updateConstraints:^(MASConstraintMaker *make) {
                make.top.mas_equalTo(self.overdueMoneyLabel.mas_bottom).offset(10 * SCREENH6);
                make.leading.mas_equalTo(self.overdueMoneyLabel);
            }];
            
            [self.autoRepayMoneyValueLabel mas_updateConstraints:^(MASConstraintMaker *make) {
                make.centerY.mas_equalTo(self.autoRepayMoneyLabel);
                make.trailing.mas_equalTo(self.overdueMoneyValueLabel);
            }];
            
            self.readyMoneyValueLabel.text = [NSString stringWithFormat:@"%.2f元",[self.detailModel.repayTotalAmount floatValue]];
//            self.autoRepayMoneyValueLabel.text = [Lahelper formattedTimeFromTimeInterval:[self.detailModel.paybackTime longLongValue]];
            self.readyMoneyValueLabel.text = [self timeWithTimeIntervalString:[NSString stringWithFormat:@"%@",self.detailModel.paybackTime]];
            self.overdueMoneyValueLabel.text = [NSString stringWithFormat:@"%@.00元",self.detailModel.overdueAmount];
            
            self.detailArray = @[@"已还金额",@"逾期滞纳金",@"自动扣款/主动扣款"];
            self.showLabel.text = @"已结清(元)";
            self.rightImageView.image = [UIImage imageNamed:@"已逾期还款"];
            self.title = @"借款详情";

        }
            break;
        default:
            break;
    }
    [self.tableView reloadData];
    [self.tableView1 reloadData];
    self.progressView.model = self.detailModel;
    [self setUpMoneyView:[self.detailModel.borrowAmount integerValue]];
//    self.serviceCostView.model =self.detailModel;

    [self updateMoneyLayout];

}


-(void)updateMoneyLayout
{
    __block CGFloat totalWidth = 20+50*(self.moneyView.subviews.count-1);
    [self.moneyView.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        [obj mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(self.moneyView);
            
            if(idx == 0)
            {
                make.width.mas_equalTo(20 * SCREENH6);
                make.height.mas_equalTo(27 * SCREENH6);
                make.leading.mas_equalTo(self.moneyView).offset((SCREEN_WIDTH-totalWidth)/2);
            }else
            {
                make.height.mas_equalTo(50 * SCREENH6);
                make.width.mas_equalTo(37 * SCREENH6);
                make.leading.mas_equalTo(self.moneyView).offset(((SCREEN_WIDTH-totalWidth)/2+33)+(idx-1)*50);
                
            }
        }];
        
    }];
}




-(void)getorderInfoComplete:(void(^)())complete
{
    ParaModel*para = [ParaModel new];
    para.applyNo = self.detailModel.applyNo;
    
    [[NetworkTool shareManager] POST:[Interfacefile getPreRepayLoanJson] Param:[para toDictionary] andWaitStr:@"" waitView:self.view success:^(id  _Nullable responseObject) {
        
        if([[responseObject objectForKey:@"code"]intValue]==0)
        {
            self.order = [[LLOrder alloc] initWithLLPayType:LLPayTypeQuick];
            self.order.errorInfo =[[responseObject objectForKey:@"data"] objectForKey:@"errorInfo"];
            self.order.oid_partner =[[responseObject objectForKey:@"data"] objectForKey:@"oid_partner"];
            self.order.oid_partner =[[responseObject objectForKey:@"data"] objectForKey:@"oid_partner"];

            self.order.sign_type =[[responseObject objectForKey:@"data"] objectForKey:@"sign_type"];
            self.order.sign =[[responseObject objectForKey:@"data"] objectForKey:@"sign"];
            self.order.busi_partner =[[responseObject objectForKey:@"data"] objectForKey:@"busi_partner"];
            self.order.no_order =[[responseObject objectForKey:@"data"] objectForKey:@"no_order"];
            self.order.dt_order =[[responseObject objectForKey:@"data"] objectForKey:@"dt_order"];
            self.order.money_order =[[responseObject objectForKey:@"data"] objectForKey:@"money_order"];
            self.order.notify_url =[[responseObject objectForKey:@"data"] objectForKey:@"notify_url"];
            self.order.risk_item =[[responseObject objectForKey:@"data"] objectForKey:@"risk_item"];
            self.order.user_id =[[responseObject objectForKey:@"data"] objectForKey:@"user_id"];
            self.order.name_goods =[[responseObject objectForKey:@"data"] objectForKey:@"name_goods"];
            self.order.info_order =[[responseObject objectForKey:@"data"] objectForKey:@"info_order"];
            self.order.valid_order =[[responseObject objectForKey:@"data"] objectForKey:@"valid_order"];
            self.order.no_agree =[[responseObject objectForKey:@"data"] objectForKey:@"no_agree"];
            self.order.id_type =[[responseObject objectForKey:@"data"] objectForKey:@"id_type"];
            self.order.id_no =[[responseObject objectForKey:@"data"] objectForKey:@"id_no"];
            self.order.acct_name =[[responseObject objectForKey:@"data"] objectForKey:@"acct_name"];
            self.order.card_no =[[responseObject objectForKey:@"data"] objectForKey:@"card_no"];
            self.order.platform =[[responseObject objectForKey:@"data"] objectForKey:@"platform"];
            self.order.shareing_data =[[responseObject objectForKey:@"data"] objectForKey:@"shareing_data"];
           
            
            
            
            complete([responseObject objectForKey:@"data"]);
        }else{
            
            [self showHint:[responseObject objectForKey:@"message"]];
            
            
        }
    } andFailure:^(NSError * _Nonnull error) {
        [self showHint:@"网络错误"];
    }];
    
}

-(void)backInfoComplete:(void(^)())complete
{
    ParaModel*para = [ParaModel new];
    
    
    [[NetworkTool shareManager] POST:[Interfacefile pushRepayResult] Param:[para toDictionary] andWaitStr:@"" waitView:self.view success:^(id  _Nullable responseObject) {
        complete();

        
    } andFailure:^(NSError * _Nonnull error) {
        complete();

    }];
    
}


- (NSString *)timeWithTimeIntervalString:(NSString *)timeString
{
    // 格式化时间
    NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
    formatter.timeZone = [NSTimeZone timeZoneWithName:@"shanghai"];
    [formatter setDateStyle:NSDateFormatterMediumStyle];
    [formatter setTimeStyle:NSDateFormatterShortStyle];
    [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    
    // 毫秒值转化为秒
    NSDate* date = [NSDate dateWithTimeIntervalSince1970:[timeString doubleValue]/ 1000.0];
    NSString* dateString = [formatter stringFromDate:date];
    return dateString;
}


-(void)pushBind:(NSDictionary*)dic complete:(void(^)())complete
{
    
    [[NetworkTool manager] POSTJson:[Interfacefile pushRepayResult] Param:dic andWaitStr:@"" waitView:self.view success:^(id  _Nullable responseObject) {
        if([[responseObject objectForKey:@"code"]intValue]==0)
        {
            complete();
        }else{
            
            [self showHint:[responseObject objectForKey:@"message"]];
            
            
        }
    } andFailure:^(NSError * _Nonnull error) {
        [self showHint:@"网络错误"];
    }];
    
}


@end
